package b1w1nn1ng.crossf1t.db;

import java.sql.SQLException;

import b1w1nn1ng.crossf1t.business.User;
import b1w1nn1ng.crossf1t.db.Database;

import junit.framework.TestCase;

public class TestDb extends TestCase{

	User user = new User("Pepsi", "Cola", "Pepsi@gmail.com", "Soda", "Pop", "What is your favorite soda?", "Pepsicola", 145, 67); //height in inches
	User newUser;
	public void setUp() throws SQLException, ClassNotFoundException{
		if(!Database.isUsername(user.getUsername())){
			newUser = Database.addUser(user);
		}
		newUser = Database.getUserByUsername(user.getUsername());
	}
	
	public void testAddUser() throws SQLException, ClassNotFoundException {
		assertEquals(user.getUsername(), newUser.getUsername());
	}

	public void testGetUserByID() throws SQLException, ClassNotFoundException {
		assertTrue(newUser.equals(Database.getUserByID(newUser.getId())));
	}

	public void testGetUserByUsername() throws SQLException, ClassNotFoundException {
		assertTrue(newUser.equals(Database.getUserByUsername(user.getUsername())));
	}

	public void testGetQuestionByUsername() throws ClassNotFoundException, SQLException {
		assertEquals("What is your favorite soda?",Database.getQuestionByUsername(user.getUsername()));
	}

	

	public void testGetData() {
		fail("Not yet implemented");
	}

	public void testIsUser() throws SQLException, ClassNotFoundException{
		assertTrue(Database.isUsername(user.getUsername()));
	}

	public void testGetWorkoutId() {
		fail("Not yet implemented");
	}

	public void testGetWorkoutById() {
		fail("Not yet implemented");
	}
	public void testAddGoal() throws SQLException, ClassNotFoundException{
		int id = newUser.getId();
		String goal = "Get laid";
		assertTrue(Database.addGoal(id, goal));
	}
	
	public void testRemoveGoal() throws SQLException, ClassNotFoundException{
		int id = newUser.getId();
		String goal = "Get laid";
		assertTrue(Database.removeGoal(id, goal));
	}
	public void testUser() throws SQLException, ClassNotFoundException{
		assertTrue(newUser.equals(Database.updateUser(newUser)));
	}

}
